package javase.homework.second;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class TeacherTest {
	public static void main(String[] args) {
		Teacher t1=new Teacher(1,"zs",11,1000);
		Teacher t2=new Teacher(2,"lisi",22,2000);
		Teacher t3=new Teacher(3,"ww",33,3000);
		Teacher t4=new Teacher(4,"zl",44,4000);
		//Set< Teacher> set= new HashSet<Teacher>();
		if(t1.namecompareTo(t2)>0){
			System.out.println("big than!!");
		};
		
		List<Teacher> set=new ArrayList<Teacher>();
		set.add(t1);
		set.add(t2);
		set.add(t3);
		set.add(t4);
		ByAge byAge=new ByAge();
		Collections.sort(set, byAge);
		System.out.println(set);
		
		
		List<String> list=new ArrayList<String>();
		list.add("aa");
		list.add("bbb");
		list.add("cccc");
		ByLength byLength=new ByLength();
		Collections.sort(list, byLength);
		System.out.println(list);
		
	}
}
class ByAge implements Comparator<Teacher>{

	@Override
	public int compare(Teacher o1, Teacher o2) {
		
		return o1.getAge()-o2.getAge();
	}
} 
class ByLength implements Comparator<String>{

	@Override
	public int compare(String o1, String o2) {
		
		return -(o1.length()-o2.length());
	}
} 